package com.wxl.asmgradleplugin.myplugin

import com.android.build.api.instrumentation.FramesComputationMode
import com.android.build.api.instrumentation.InstrumentationScope
import com.android.build.api.variant.AndroidComponentsExtension
import org.gradle.api.Plugin
import org.gradle.api.Project

class MyPlugin2 : Plugin<Project> {
    override fun apply(project: Project) {
        println("---------------MyPlugin2 222------------------")
        val androidComponents = project.extensions.getByType(AndroidComponentsExtension::class.java)
        /*
         * androidComponentsExtension.selector().withBuildType("release")
         */
        androidComponents.onVariants { variant ->
            println("---------------222 variant=$variant")
            /*
             * InstrumentationScope.PROJECT=app
             * InstrumentationScope.ALL=app+library
             */
            variant.instrumentation.transformClassesWith(
                LogClassVisitorFactory::class.java, InstrumentationScope.ALL
            ) { params ->
                params.param = "wxl666"
            }
            variant.instrumentation.setAsmFramesComputationMode(FramesComputationMode.COPY_FRAMES)
        }
    }
}